package com.chillis.standings.dispatch;

import com.chillis.standings.domain.table.Table;
import com.chillis.standings.domain.table.TableSettings;
import com.chillis.standings.domain.table.TablesFactory;

public class TableManager {
   private static TableManager _instance;

   public static TableManager instance() {
      if (_instance == null) {
         _instance = new TableManager();
      }

      return _instance;
   }

   private TableManager() {
   }

   public void updateSettings(TableSettings.Format format, int participantsCount) {
      _table = TablesFactory.create(format, participantsCount);
   }

   public Table table() {
      if (_table == null) {
         throw new Error("table wasn't initialized");
      }

      return _table;
   }

   private Table _table;
}
